<?php
namespace app\api\validate;

use \think\Validate;

class Member extends Validate
{
    protected $rule = [
        'username' => 'require|checkMobile|unique:member',
        'password' => 'require|length:6,25',
        'yzm' => 'require',
    ];

    protected $message = [
        'username.require' => '请填写手机号',
        'username.checkMobile' => '手机号格式不正确',
        'username.unique' => '手机号已被注册',
        'password.require' => '密码不能为空',
        'password.length' => '密码长度6-25位',
        'yzm.require' => '验证码不能为空',
    ];
	
	
	// 自定义验证规则方法
    protected function checkMobile($value) {
        return preg_match('/^1[3-9]\d{9}$/', $value) ? true : false;
    }
	
	protected $scene = [
        'reg'   =>  ['username','password','yzm'],
        'log'  =>  ['password'],
        'log_yzm'  =>  ['password','yzm'],
    ];    
}